clear
clear matrix
clear mata
set matsize 4000
set maxvar 10000

*Note: first change working directory replication package folder

run "scripts/programs/program_data.do"
run "scripts/programs//program_regs.do"
run "scripts/programs/program_regtable.do"
run "scripts/programs/program_coefmat.do"
run "scripts/programs/program_coefscatter.do"

/*********************************************************************************/
*Set program parameters
local radius = 20
local angle = 15
local length = 1
/*********************************************************************************/

data anypop pop anyhu hu hudens lnpop popdens inc_pcincome inc_totinc inc_huxpcinc inc_pct_poverty ///
	count_res count_mobile count_sfr ///
	any_res val_res val_mobile val_sfr count_vac_hu count_nonvac_hu ///
	avgval_res avgval_mobile avgval_sfr ///
	race_pct_whitenh race_pct_amind ///
	race_pct_black race_pct_hisp tenure_pct_rent vac_pct_vacation tri  ///
	lnt lnint t1 t2 t3 t4 t5 t6 tmissing roadpcttot majorroad tritot habpolytot hablinetot wsimptot ///
	campground wilderness ///
	using "data/`radius'-by-`length'km_`angle'deg/data_centroid.dta", ///
	maxlags(0) maxleads(0) burnt(centroid) tcuts(1,2,3,4,5,8)

merge m:1 firenum using ///
	"data/`radius'-by-`length'km_`angle'deg/sample_census.dta", ///
	nogen

keep if sample == 1

/************************* ROBUSTNESS - Census ******************************/

capture drop sample

replace race_pct_whitenh = 0 if count_res == 0
replace inc_pct_poverty = 0 if count_res == 0
replace inc_pcincome = 0 if count_res== 0
replace tenure_pct_rent = 0 if count_res == 0

local huvars anyhu count_vac_hu count_nonvac_hu inc_pcincome huxpcinc tenure_pct_rent
local indepvars tritot roadpcttot habpolytot wsimptot campground wilderness
local firevars lnt lnint majorroad tmissing wind_diff
local demvars `huvars' `indepvars'

set matsize 4000
local link cloglog
regs y `demvars' `firevars' if complexfire != 1, link(`link') cluster(firenum) save(fe) fe(firenum)
regs y `demvars' `firevars' if sample == 1 & complexfire != 1, link(`link') cluster(firenum) save(both)
regs y `demvars' if sample == 1 & complexfire != 1, link(`link') cluster(firenum) save(fe_base) fe(firenum)
regs y `firevars' if sample == 1 & complexfire != 1, link(`link') cluster(firenum) save(fe_fire) fe(firenum)

local dir "Results/Robustness_Table_Vacation/"
capture mkdir `dir'
noi regtable fe_base fe_fire both fe logit probit lpm using "`dir'table_contents.tex" ///
 	, keep(`demvars' `firevars') tex
